package com.ljl.handlers;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/test")
public class MyController {
	@RequestMapping("/toWelcome.do")
	public String toWelcome(){
		return "welcome";
	}
	
	@RequestMapping("/testJson1.do")
	public String testJson1(@RequestParam Map<String, Object> map){
		System.out.println(map);// {name=韦德, age=35}
		return "welcome";
	}
	
	@RequestMapping("/testJson2.do")
	public String testJson2(@RequestBody Map<String, Object> map){
		System.out.println(map);// {name=韦德, win=[2006, 2012, 2013], age=35}
		return "welcome";
	}
	
	@RequestMapping("/testJson3.do")
	@ResponseBody
	public Map<String, Object> testJson3(){
		Map<String, Object> result = new HashMap<String, Object>();
		  result.put("name", "韦德");
		  result.put("age", 35);
		  return result;
	}
}
